
public class Pay {
	
	public static int getLotRent(int x) {
		
		Player a = LotTiles.values()[x].getOwner();
		Properties b = a.getProperties();
		
		//Checks hotel
		if (LotTiles.values()[x].getHotel() == true) {
			
			return LotTiles.values()[x].getRentHotel();
		}
		
		//Checks number of houses
		else if (LotTiles.values()[x].getNumHouse() != 0) {
			
			switch(LotTiles.values()[x].getNumHouse()) {
			
				case 1:
					return LotTiles.values()[x].getRent1();
				case 2:
					return LotTiles.values()[x].getRent2();
				case 3:
					return LotTiles.values()[x].getRent3();
				case 4:
					return LotTiles.values()[x].getRent4();
			}
		}
		
		//Checks if all lots owned
		else if (b.checkIfAllLotsOwned(a, LotTiles.values()[x].getColor()) == true) {
			
			return LotTiles.values()[x].getRent()*2;
		}
		
		//Returns normal rent
		return LotTiles.values()[x].getRent();
	}
	
	public static int getTrainRent(int x) {
		
		if (x == 4) {
			
			return TrainTiles.values()[0].getRent4();
		}
		
		else if (x == 3) {
			
			return TrainTiles.values()[0].getRent3();
		}
		
		else if (x == 2) {
			
			return TrainTiles.values()[0].getRent2();
		}
		
		else {
			
			return TrainTiles.values()[0].getRent();
		}
	}
	
	public static Player payLotRent(Player a, int x) {
		
		Player owner = LotTiles.values()[x].getOwner();
		int rent = Pay.getLotRent(x);
		
		if (a.getCash() >= rent) {
			
			a.setCash(a.getCash()-rent);
			owner.setCash(owner.getCash()+rent);
		}
		
		else {
			
			//CALL JFRAME SHIZ;
		}
		
		return a;
	}
	
	public static Player payTrainRent(Player a, int x) {
		
		Properties properties = a.getProperties();
		Player owner = TrainTiles.values()[x].getOwner();
		int rent = Pay.getTrainRent(properties.getTrainCount());
		
		if (a.getCash() >= rent) {
			
			a.setCash(a.getCash()-rent);
			owner.setCash(owner.getCash()+rent);
		}
		
		else {
			
			//CALL JFRAME SHIZ;
		}
		
		return a;
	}
	
	public static Player payUtilitiesRent(Player a, int x) {
		
		Properties properties = a.getProperties();
		Player owner = UtilitiesTiles.values()[x].getOwner();
		Dice dice = a.getDice();
		int rent;
		
		if (properties.getUtilityCount() == 2) {
			
			rent = dice.getSum()*10;
		}
		
		else {
			
			rent = dice.getSum()*4;
		}
		
		if (a.getCash() >= rent) {
			
			a.setCash(a.getCash()-rent);	
			owner.setCash(owner.getCash()+rent);
		}
		
		else {
			
			//CALL JFRAME SHIZ;
		}
		
		return a;
	}
}
